<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// 后台管理使用
Route::post('/quick/catch', [\App\Http\Controllers\Api\QuickController::class, 'catch'])->name('quick.catch');
Route::post('dynamic/del', [\App\Http\Controllers\Api\DynamicController::class, 'del'])->name('dynamic.del');

Route::get('/site/wx-callback', [\App\Http\Controllers\Api\SiteController::class, 'wxCallback'])->name('site.wx-callback');

// 前端提交formData，签名验证无法通过
Route::middleware([
    \App\Http\Middleware\GetLoginUser::class,
    \App\Http\Middleware\CheckLogin::class,
])->group(function () {
    // 用户
    Route::post('/user/avatar', [\App\Http\Controllers\Api\UserController::class, 'avatar'])->name('user.avatar');

    // 分享
    Route::middleware([])->prefix('share')->group(function () {
        Route::post('/upload', [\App\Http\Controllers\Api\ShareController::class, 'upload'])->name('share.upload');
    });

    // 侵权
    Route::middleware([])->prefix('tort')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\TortController::class, 'add'])->name('tort.add');
    });
});

Route::middleware([
    \App\Http\Middleware\VerifyParamsEncrypt::class,
    \App\Http\Middleware\GetLoginUser::class,
])->group(function () {
    // 协议
    Route::post('/agreement/get-detail', [\App\Http\Controllers\Api\AgreementController::class, 'getDetail'])->name('agreement.get-detail');

    // 文章
    Route::post('/article/get-detail', [\App\Http\Controllers\Api\ArticleController::class, 'getDetail'])->name('article.get-detail');
    Route::post('/article/similar', [\App\Http\Controllers\Api\ArticleController::class, 'similarList'])->name('article.similarList');

    Route::post('/note/choice-list', [\App\Http\Controllers\Api\NoteController::class, 'choiceList'])->name('note.choiceList');

    // 评论
    Route::post('/comment/list', [\App\Http\Controllers\Api\CommentController::class, 'getList'])->name('comment.list');

    // 动态
    Route::post('/dynamic/get-detail', [\App\Http\Controllers\Api\DynamicController::class, 'getDetail'])->name('dynamic.get-detail');

    // 行业
    Route::post('/industry/list', [\App\Http\Controllers\Api\IndustryController::class, 'getList'])->name('industry.list');

    // 职业
    Route::post('/job/list', [\App\Http\Controllers\Api\JobController::class, 'getList'])->name('job.list');

    // 验证登录态、退登
    Route::post('/inter/allow', [\App\Http\Controllers\Api\InterController::class, 'allow'])->name('inter.allow');
    Route::post('/inter/logout', [\App\Http\Controllers\Api\InterController::class, 'logout'])->name('inter.logout');

    // 消息
    Route::post('/message/unread', [\App\Http\Controllers\Api\MessageController::class, 'unread'])->name('message.unread');

    // 笔记
    Route::post('/note/article-list', [\App\Http\Controllers\Api\NoteController::class, 'articleList'])->name('note.article-list');
    Route::post('/note/line-list', [\App\Http\Controllers\Api\NoteController::class, 'lineList'])->name('note.line-list');
    Route::post('/note/get-detail', [\App\Http\Controllers\Api\NoteController::class, 'getDetail'])->name('note.get-detail');

    // 收藏夹
    Route::post('/package/get-detail', [\App\Http\Controllers\Api\PackageController::class, 'getDetail'])->name('package.get-detail');
    Route::post('/package/more-list', [\App\Http\Controllers\Api\PackageController::class, 'moreList'])->name('package.more-list');
    Route::post('/package/target-list', [\App\Http\Controllers\Api\PackageController::class, 'targetList'])->name('package.target-list');
    Route::post('/package/list', [\App\Http\Controllers\Api\PackageController::class, 'getList'])->name('package.list');

    // 智囊团
    Route::post('/pro-category/list', [\App\Http\Controllers\Api\ProCategoryController::class, 'getList'])->name('pro-category.list');
    Route::post('/pro/list', [\App\Http\Controllers\Api\ProController::class, 'getList'])->name('pro.list');
    Route::post('/pro/recommend-list', [\App\Http\Controllers\Api\ProController::class, 'recommendList'])->name('pro.recommend-list');

    // 关注关系
    Route::post('/relationship/follower', [\App\Http\Controllers\Api\RelationshipController::class, 'follower'])->name('relationship.follower');
    Route::post('/relationship/following', [\App\Http\Controllers\Api\RelationshipController::class, 'following'])->name('relationship.following');

    // 登录
    Route::post('/site/phone-login', [\App\Http\Controllers\Api\SiteController::class, 'phoneLogin'])->name('site.phone-login');
    Route::post('/site/pwd-login', [\App\Http\Controllers\Api\SiteController::class, 'pwdLogin'])->name('site.pwd-login');
    Route::post('/site/bind-wx', [\App\Http\Controllers\Api\SiteController::class, 'bindWx'])->name('bind-wx');

    // 搜索
    Route::post('/search/article', [\App\Http\Controllers\Api\SearchController::class, 'article'])->name('search.article');
    Route::post('/search/note', [\App\Http\Controllers\Api\SearchController::class, 'note'])->name('search.note');
    Route::post('/search/topic', [\App\Http\Controllers\Api\SearchController::class, 'topic'])->name('search.topic');
    Route::post('/search/user', [\App\Http\Controllers\Api\SearchController::class, 'user'])->name('search.user');

    // 回复
    Route::post('/reply/list', [\App\Http\Controllers\Api\ReplyController::class, 'getList'])->name('reply.list');

    // 广场
    Route::post('/square/recommend-list', [\App\Http\Controllers\Api\SquareController::class, 'recommendList'])->name('square.recommend-list');

    // 用户
    Route::post('/user/dynamic-list', [\App\Http\Controllers\Api\UserController::class, 'dynamicList'])->name('user.dynamic-list');
    Route::post('/user/dynamic-landing', [\App\Http\Controllers\Api\UserController::class, 'dynamicLanding'])->name('user.dynamic-landing');
    Route::post('/user/get-detail', [\App\Http\Controllers\Api\UserController::class, 'getDetail'])->name('user.get-detail');
    Route::post('/user/article-list', [\App\Http\Controllers\Api\UserController::class, 'articleList'])->name('user.article-list');
    Route::post('/user/like-list', [\App\Http\Controllers\Api\UserController::class, 'likeList'])->name('user.like-list');
    Route::post('/user/note-list', [\App\Http\Controllers\Api\UserController::class, 'noteList'])->name('user.note-list');
    Route::post('/user/package-list', [\App\Http\Controllers\Api\UserController::class, 'packageList'])->name('user.package-list');

    // 短信
    Route::post('/sms/send', [\App\Http\Controllers\Api\SmsController::class, 'send'])->name('sms.send');

    // 话题
    Route::post('/topic/get-detail', [\App\Http\Controllers\Api\TopicController::class, 'getDetail'])->name('topic.getDetail');
    Route::post('/topic/prompt', [\App\Http\Controllers\Api\TopicController::class, 'promptList'])->name('topic.promptList');
    Route::post('/topic/hot', [\App\Http\Controllers\Api\TopicController::class, 'hotList'])->name('topic.hotList');

    // 沙龙
    Route::middleware([])->prefix('salon')->group(function () {
        Route::post('/list', [\App\Http\Controllers\Api\SalonController::class, 'getList'])->name('salon.getList');
        Route::post('/review', [\App\Http\Controllers\Api\SalonController::class, 'reviewList'])->name('salon.reviewList');
        Route::post('/get-detail', [\App\Http\Controllers\Api\SalonController::class, 'getDetail'])->name('salon.get-detail');
    });
});

// 需要验证签名、验证登录态
Route::middleware([
    \App\Http\Middleware\VerifyParamsEncrypt::class,
    \App\Http\Middleware\CheckLogin::class,
    \App\Http\Middleware\GetLoginUser::class,
])->group(function () {
    // 收藏
    Route::middleware([])->prefix('collect')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\CollectController::class, 'add'])->name('collect.add');
        Route::post('/cancel', [\App\Http\Controllers\Api\CollectController::class, 'cancel'])->name('collect.cancel');
    });

    // 评论
    Route::middleware([])->prefix('comment')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\CommentController::class, 'add'])->name('comment.add');
        Route::post('/del', [\App\Http\Controllers\Api\CommentController::class, 'del'])->name('comment.del');
    });

    // 意见反馈
    Route::middleware([])->prefix('feedback')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\FeedbackController::class, 'add'])->name('feedback.add');
    });

    // 桌面
    Route::middleware([])->prefix('home')->group(function () {
        Route::post('/collect-list', [\App\Http\Controllers\Api\HomeController::class, 'collectList'])->name('home.collect-list');
        Route::post('/note-list', [\App\Http\Controllers\Api\HomeController::class, 'noteList'])->name('home.note-list');
        Route::post('/package-list', [\App\Http\Controllers\Api\HomeController::class, 'packageList'])->name('home.package-list');
    });

    // 行业
    Route::middleware([])->prefix('industry')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\IndustryController::class, 'add'])->name('industry.add');
    });

    // 工作
    Route::middleware([])->prefix('job')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\JobController::class, 'add'])->name('job.add');
    });

    // 点赞
    Route::middleware([])->prefix('like')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\LikeController::class, 'add'])->name('like.add');
        Route::post('/cancel', [\App\Http\Controllers\Api\LikeController::class, 'cancel'])->name('like.cancel');
    });

    // 消息
    Route::middleware([])->prefix('message')->group(function () {
        Route::post('/announce', [\App\Http\Controllers\Api\MessageController::class, 'announce'])->name('message.announce');
        Route::post('/clean', [\App\Http\Controllers\Api\MessageController::class, 'clean'])->name('message.clean');
        Route::post('/comment-receive', [\App\Http\Controllers\Api\MessageController::class, 'commentReceive'])->name('message.comment-receive');
        Route::post('/comment-send', [\App\Http\Controllers\Api\MessageController::class, 'commentSend'])->name('message.comment-send');
        Route::post('/like', [\App\Http\Controllers\Api\MessageController::class, 'like'])->name('message.like');
    });

    // 笔记
    Route::middleware([])->prefix('note')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\NoteController::class, 'add'])->name('note.add');
        Route::post('/add-line', [\App\Http\Controllers\Api\NoteController::class, 'addLine'])->name('note.add-line');
        Route::post('/del', [\App\Http\Controllers\Api\NoteController::class, 'del'])->name('note.del');
        Route::post('/edit', [\App\Http\Controllers\Api\NoteController::class, 'edit'])->name('note.edit');
    });

    // 收藏夹
    Route::middleware([])->prefix('package')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\PackageController::class, 'add'])->name('package.add');
        Route::post('/del', [\App\Http\Controllers\Api\PackageController::class, 'del'])->name('package.del');
        Route::post('/edit', [\App\Http\Controllers\Api\PackageController::class, 'edit'])->name('package.edit');
        Route::post('/quick-list', [\App\Http\Controllers\Api\PackageController::class, 'quickList'])->name('package.quick-list');
    });

    // 一键收藏
    Route::middleware([])->prefix('quick')->group(function () {
        Route::post('/collect', [\App\Http\Controllers\Api\QuickController::class, 'collect'])->name('quick.collect');
        Route::post('/preview', [\App\Http\Controllers\Api\QuickController::class, 'preview'])->name('quick.preview');
    });

    // 关注关系
    Route::middleware([])->prefix('relationship')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\RelationshipController::class, 'add'])->name('relationship.add');
        Route::post('/cancel', [\App\Http\Controllers\Api\RelationshipController::class, 'cancel'])->name('relationship.cancel');
    });

    // 回复
    Route::middleware([])->prefix('reply')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\ReplyController::class, 'add'])->name('reply.add');
        Route::post('/del', [\App\Http\Controllers\Api\ReplyController::class, 'del'])->name('reply.del');
    });

    // 举报
    Route::middleware([])->prefix('report')->group(function () {
        Route::post('/list', [\App\Http\Controllers\Api\ReportController::class, 'getList'])->name('report.getList');
        Route::post('/add', [\App\Http\Controllers\Api\ReportController::class, 'add'])->name('report.add');
    });

    // 广场
    Route::middleware([])->prefix('square')->group(function () {
        Route::post('/attention-list', [\App\Http\Controllers\Api\SquareController::class, 'attentionList'])->name('square.attention-list');
    });

    // 用户
    Route::middleware([])->prefix('user')->group(function () {
        Route::post('/change-phone', [\App\Http\Controllers\Api\UserController::class, 'changePhone'])->name('user.change-phone');
        Route::post('/edit', [\App\Http\Controllers\Api\UserController::class, 'edit'])->name('user.edit');
        Route::post('/get-info', [\App\Http\Controllers\Api\UserController::class, 'getInfo'])->name('user.get-info');
        Route::post('/re-pwd', [\App\Http\Controllers\Api\UserController::class, 'rePwd'])->name('user.re-pwd');
        Route::post('/unbind-wx', [\App\Http\Controllers\Api\UserController::class, 'unbindWx'])->name('user.unbind-wx');
    });

    // 用户推荐
    Route::middleware([])->prefix('recommend')->group(function () {
        Route::post('/add', [\App\Http\Controllers\Api\RecommendController::class, 'add'])->name('recommend.add');
        Route::post('/cancel', [\App\Http\Controllers\Api\RecommendController::class, 'cancel'])->name('recommend.cancel');
    });
});

// test route
Route::any('/redirect/article', [\App\Http\Controllers\Api\RedirectController::class, 'article'])->name('redirect.article');
Route::any('/test/cache', [\App\Http\Controllers\Api\TestController::class, 'cache'])->name('test.cache');
Route::any('/test/redis', [\App\Http\Controllers\Api\TestController::class, 'redis'])->name('test.redis');
Route::any('/test/queue', [\App\Http\Controllers\Api\TestController::class, 'queue'])->name('test.queue');
Route::any('/test/event', [\App\Http\Controllers\Api\TestController::class, 'event'])->name('test.event');
Route::any('/test/http', [\App\Http\Controllers\Api\TestController::class, 'http'])->name('test.http');
Route::any('/test/download', [\App\Http\Controllers\Api\TestController::class, 'download'])->name('test.download');
Route::post('/test/upload', [\App\Http\Controllers\Api\TestController::class, 'upload'])->name('test.upload');
Route::post('/test/oss', [\App\Http\Controllers\Api\TestController::class, 'oss'])->name('test.oss');
Route::any('/test/es', [\App\Http\Controllers\Api\TestController::class, 'es'])->name('test.es');
Route::any('/test/sms', [\App\Http\Controllers\Api\TestController::class, 'sms'])->name('test.sms');

// temp api
// [!] 临时接口，管理后台迁移完成后会被废弃掉
Route::post('/temp/get-cache', [\App\Http\Controllers\Api\TempController::class, 'getCache'])->name('temp.get-cache');
Route::post('/temp/set-cache', [\App\Http\Controllers\Api\TempController::class, 'setCache'])->name('temp.set-cache');
